package interrupt;

/**
 * stop 中断线程会导致线程暴力退出，没有执行完毕，引发安全问题
 */
public class StopDemo implements Runnable {
    private static int i = 0;
    private static int j = 0;

    @Override
    public void run() {
        i++;
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        j++;
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new StopDemo());
        thread.start();
        Thread.sleep(1000);
        thread.stop();
        System.out.println("i>" + i);
        System.out.println("j>" + j);
    }
}
